<?php

namespace Tools\Utils;

class File
{
    /**
     * 文件调试
     * @param $content
     */
    public static function debug_file($content, string $fileName = 'error', string $ext = 'txt')
    {
        $msg = '[' . date('Y-m-d H:i:s', time()) . '] [ DEBUG ] ';

        $path = BASE_PATH . DIRECTORY_SEPARATOR . 'debugfile' . DIRECTORY_SEPARATOR;

        if (!is_dir($path)) {
            mkdir($path);
        }

        $fileName = $fileName . '_' . date('Y-m') . '.' . $ext;
        $file = $path . $fileName;
        file_put_contents($file, $msg . print_r($content, true) . "\r\n", FILE_APPEND);
    }
}
